using System.Collections.Generic;
using System.Linq;
using WalkingTec.Mvvm.Core;
using HengTong.Model.Db.System;


namespace HengTong.ViewModel._Admin.SysSiteConfigVms
{
    public partial class SysSiteConfigListVm : BasePagedListVM<SysSiteConfigView, SysSiteConfigSearcher>
    {

        protected override IEnumerable<IGridColumn<SysSiteConfigView>> InitGridHeader()
        {
            return new List<GridColumn<SysSiteConfigView>>{
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.LogoId).SetFormat(LogoIdFormat),
                this.MakeGridHeader(x => x.CustomGroupCode),
                this.MakeGridHeader(x => x.CustomJobPositionCode),
                this.MakeGridHeader(x => x.SmsLogin),
                this.MakeGridHeader(x => x.WechatLogin),
                this.MakeGridHeader(x => x.WechatMpAppId),
                this.MakeGridHeader(x => x.WechatMpAppSecret),
                this.MakeGridHeader(x => x.WechatWebAppId),
                this.MakeGridHeader(x => x.WechatWebSecret),
                this.MakeGridHeader(x => x.WechatWebRedirectUri),
                this.MakeGridHeader(x => x.WechatAppAppId),
                this.MakeGridHeader(x => x.WechatAppSecret),
                this.MakeGridHeader(x => x.WechatAppRedirectUri),
                this.MakeGridHeader(x => x.SmsAppId),
                this.MakeGridHeader(x => x.SmsHost),
                this.MakeGridHeader(x => x.SmsSecretName),
                this.MakeGridHeader(x => x.SmsSecretKey),
                this.MakeGridHeader(x => x.SmsTemplate),
                this.MakeGridHeader(x => x.AliyunOcrAppKey),
                this.MakeGridHeader(x => x.AliyunOcrAppSecret),
                this.MakeGridHeader(x => x.AliyunOcrAppCode),
                this.MakeGridHeader(x => x.TenantCode),
                this.MakeGridHeader(x => x.ControlConfig),
                this.MakeGridHeader(x => x.SubstitutionMonthlyLimit),
                this.MakeGridHeaderAction(width: 200)
            };
        }
        private List<ColumnFormatInfo> LogoIdFormat(SysSiteConfigView entity, object val)
        {
            return new List<ColumnFormatInfo>
            {
                ColumnFormatInfo.MakeDownloadButton(ButtonTypesEnum.Button,entity.LogoId),
                ColumnFormatInfo.MakeViewButton(ButtonTypesEnum.Button,entity.LogoId,640,480),
            };
        }


        public override IOrderedQueryable<SysSiteConfigView> GetSearchQuery()
        {
            var query = DC.Set<SysSiteConfig>()
                .Select(x => new SysSiteConfigView
                {
				    ID = x.ID,
                    Name = x.Name,
                    LogoId = x.LogoId,
                    CustomGroupCode = x.CustomGroupCode,
                    CustomJobPositionCode = x.CustomJobPositionCode,
                    SmsLogin = x.SmsLogin,
                    WechatLogin = x.WechatLogin,
                    WechatMpAppId = x.WechatMpAppId,
                    WechatMpAppSecret = x.WechatMpAppSecret,
                    WechatWebAppId = x.WechatWebAppId,
                    WechatWebSecret = x.WechatWebSecret,
                    WechatWebRedirectUri = x.WechatWebRedirectUri,
                    WechatAppAppId = x.WechatAppAppId,
                    WechatAppSecret = x.WechatAppSecret,
                    WechatAppRedirectUri = x.WechatAppRedirectUri,
                    SmsAppId = x.SmsAppId,
                    SmsHost = x.SmsHost,
                    SmsSecretName = x.SmsSecretName,
                    SmsSecretKey = x.SmsSecretKey,
                    SmsTemplate = x.SmsTemplate,
                    AliyunOcrAppKey = x.AliyunOcrAppKey,
                    AliyunOcrAppSecret = x.AliyunOcrAppSecret,
                    AliyunOcrAppCode = x.AliyunOcrAppCode,
                    TenantCode = x.TenantCode,
                    ControlConfig = x.ControlConfig,
                    SubstitutionMonthlyLimit = x.SubstitutionMonthlyLimit,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class SysSiteConfigView : SysSiteConfig{

    }
}
